home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VBE20SRC.ZIP / VGOVBE20.ASM < prev    next >
Assembly Source File  |  1997-03-25  |  22KB  |  1,030 lines

  1. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. ; File        : VGOVBE20.ASM
  3. ; Description : VBE 2.0 interface routines
  4. ; Notes       : Brought to you by Vertigo. If you use this, or have 
  5. ;            learned from this, send us an email and/or Greet us
  6. ;               In your demo =).
  7. ;
  8. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  9. ;
  10. ; Modification History
  11. ; --------------------
  12. ;
  13. ; v1.0 -
  14. ; 08-06-96    - Rewritten new VBE 2.0 core            - TimJ
  15. ; 05-10-96    - Added vbeGetModeInfo                 - TimJ
  16. ; 24-10-96    - vbeGetModeInfo returns all VBE mode info    - TimJ
  17. ; 24-03-96      - Released                                      - Vertigo
  18. ;
  19. ; A nice fast clean VBE 2.0 assembly interface. This does everything you
  20. ; need including the mapping of low mem VBE pointers and strings into
  21. ; protected mode memory.
  22. ; It's all self contained and the header file is VGOVBE20.H
  23. ;
  24. ; The only major thing it lacks is it's own Virtual Linear Frame buffer
  25. ; code.
  26. ;
  27.  
  28.  
  29. .486p
  30. SMART
  31. JUMPS
  32. LOCALS
  33.  
  34. _TEXT   segment use32 dword public 'CODE'
  35. _TEXT   ends
  36. _DATA   segment use32 dword public 'DATA'
  37. _DATA   ends
  38. _BSS    segment use32 dword public 'BSS'
  39. _BSS    ends
  40.  
  41. DGROUP  group _DATA, _BSS
  42. assume  cs:_TEXT, ds:DGROUP
  43.  
  44. ; Note, for TASM 3.1, all 32 bit data global/extrn references must be 
  45. ; placed in a 32 bit data segment.
  46.  
  47. _CODEseg equ    _TEXT   segment use32 dword public 'CODE'
  48. _DATAseg equ    _DATA   segment use32 dword public 'DATA'
  49.  
  50. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  51. ; CODE
  52. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  53. _TEXT   segment use32 dword public 'CODE'
  54.     assume  cs:_TEXT,ds:_DATA
  55.  
  56. global    vbeDetect_:proc
  57. global    vbeGetModeInfo_:proc
  58. global    vbeOpen_:proc
  59. global    vbeClose_:proc
  60. global    vbeSetScanWidth_:proc
  61. global    vbeGetScanWidth_:proc
  62. global    vbeGetDisplayStart_:proc
  63. global    vbeSetDisplayStart_:proc
  64.  
  65.  
  66. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  67. ; vbeDetect
  68. ; Detect and get VBE info
  69. ;
  70. ; In:
  71. ;   NONE
  72. ;
  73. ; Out:
  74. ;    EAX - returns pointer to a VBEINFO structure,
  75. ;          or NULL on failure
  76. ;
  77. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  78. vbeDetect_    proc
  79.  
  80.     pushad
  81.  
  82.  
  83.     ; Allocate low memory buffer for
  84.     ; communcation with VBE
  85.  
  86.     mov    ax, 0100h
  87.     mov    bx, 512/16
  88.     int    031h
  89.     jnc    @@vbedetectl1
  90.  
  91.     popad
  92.     xor    eax,eax
  93.     ret
  94.  
  95. @@vbedetectl1:
  96.  
  97.  
  98.     ; Save the real mode info
  99.  
  100.     mov    ecx,eax
  101.     and    ecx,0FFFFh
  102.     shl    ecx,4
  103.     mov    dosmem_address,ecx        ; save linear address
  104.     mov    dosmem_segment,ax
  105.     mov    dosmem_selector,dx
  106.  
  107.  
  108.     ; Request VBE 2.0 info
  109.  
  110.     mov    dword ptr [ecx].VBEINFOBLOCK.VbeSignature,'2EBV'
  111.  
  112.  
  113.     ; Get the VBE infomation block
  114.  
  115.     mov     edi,offset RMREGS
  116.     mov     rm_eax, 04f00h
  117.     mov     rm_es, ax
  118.     mov     rm_edi, 0
  119.  
  120.     mov     ax, 0300h            ; simulate real mode int
  121.     mov     bl, 010h
  122.     mov    bh, 0
  123.     mov     cx, 0
  124.     int     031h
  125.     jc    @@error                ; DPMI error
  126.     mov    eax,rm_eax
  127.     cmp     al,04fh
  128.     jne    @@error                ; vbe not detected
  129.  
  130.     mov    esi,dosmem_address
  131.     cmp    dword ptr [esi].VBEINFOBLOCK.VbeSignature,'ASEV'
  132.     jne    @@error                ; Not VESA!
  133.  
  134.  
  135.     ; Copy the block into protected mode memory
  136.  
  137.     mov    edi, offset vbeInfo
  138.     mov    ecx, size vbeInfo
  139.     rep    movsb
  140.  
  141.  
  142.  
  143.     ; Copy needed information into a local buffer
  144.     ; and fix up the addresses in the vbeInfo block
  145.  
  146.     mov    ebp, offset vbeInfo        ; pmode vbeinfo block
  147.     mov    edi, offset localBuf        ; local buffer
  148.  
  149.  
  150.     ; Copy the mode list
  151.  
  152.     mov    eax, dosmem_address
  153.     mov    esi, [eax].VBEINFOBLOCK.VideoModePtr
  154.     mov     eax, esi
  155.     and     eax, 0ffffh
  156.     shr     esi, 16
  157.     and     esi, 0ffffh
  158.     shl     esi, 4
  159.     add     esi, eax            ; eax = linear addr
  160.  
  161.     mov    [ebp].VBEINFOBLOCK.VideoModePtr,edi
  162.  
  163. @@vbedetectl2:
  164.     lodsw
  165.     cmp    ax,-1                ; end of list
  166.     je    @@vbedetectl3
  167.     stosw
  168.     jmp    @@vbedetectl2
  169. @@vbedetectl3:
  170.     stosw                                   ; terminate list
  171.  
  172.     ; Copy the OEM string
  173.  
  174.     mov    eax, dosmem_address
  175.     mov    esi, [eax].VBEINFOBLOCK.OemStringPtr
  176.     mov     eax, esi
  177.     and     eax, 0ffffh
  178.     shr     esi, 16
  179.     and     esi, 0ffffh
  180.     shl     esi, 4
  181.     add     esi, eax            ; eax = linear addr
  182.  
  183.     mov    [ebp].VBEINFOBLOCK.OemStringPtr,edi
  184.  
  185. @@vbedetectl4:
  186.     lodsb
  187.     cmp    al,0                ; end of list
  188.     je    @@vbedetectl5
  189.     stosb
  190.     jmp    @@vbedetectl4
  191. @@vbedetectl5:
  192.     xor    al,al                ; NULL terminate string
  193.     stosb
  194.  
  195.  
  196.     ; Copy VBE 2.0 Strings to the local buffer
  197.  
  198.     mov    eax, dosmem_address
  199.     cmp    [eax].VBEINFOBLOCK.VbeVersion,0200h
  200.     jl    @@vbedetect_NOTVBE2
  201.  
  202.     ; OEM Vendor Name
  203.  
  204.     mov    eax, dosmem_address
  205.     mov    esi, [eax].VBEINFOBLOCK.OemVendorNamePtr
  206.     mov     eax, esi
  207.     and     eax, 0ffffh
  208.     shr     esi, 16
  209.     and     esi, 0ffffh
  210.     shl     esi, 4
  211.     add     esi, eax            ; eax = linear addr
  212.  
  213.     mov    [ebp].VBEINFOBLOCK.OemVendorNamePtr,edi
  214.  
  215. @@vbedetectl6:
  216.     lodsb
  217.     cmp    al,0                ; end of list
  218.     je    @@vbedetectl7
  219.     stosb
  220.     jmp    @@vbedetectl6
  221. @@vbedetectl7:
  222.     xor    al,al                ; NULL terminate string
  223.     stosb
  224.  
  225.     ; OEM Product Name
  226.  
  227.     mov    eax, dosmem_address
  228.     mov    esi, [eax].VBEINFOBLOCK.OemProductNamePtr
  229.     mov     eax, esi
  230.     and     eax, 0ffffh
  231.     shr     esi, 16
  232.     and     esi, 0ffffh
  233.     shl     esi, 4
  234.     add     esi, eax            ; eax = linear addr
  235.  
  236.     mov    [ebp].VBEINFOBLOCK.OemProductNamePtr,edi
  237.  
  238. @@vbedetectl8:
  239.     lodsb
  240.     cmp    al,0                ; end of list
  241.     je    @@vbedetectl9
  242.     stosb
  243.     jmp    @@vbedetectl8
  244. @@vbedetectl9:
  245.     xor    al,al                ; NULL terminate string
  246.     stosb
  247.  
  248.     ; OEM Vendor Revision
  249.  
  250.     mov    eax, dosmem_address
  251.     mov    esi, [eax].VBEINFOBLOCK.OemProductRevPtr
  252.     mov     eax, esi
  253.     and     eax, 0ffffh
  254.     shr     esi, 16
  255.     and     esi, 0ffffh
  256.     shl     esi, 4
  257.     add     esi, eax            ; eax = linear addr
  258.  
  259.     mov    [ebp].VBEINFOBLOCK.OemProductRevPtr,edi
  260.  
  261. @@vbedetectl10:
  262.     lodsb
  263.     cmp    al,0                ; end of list
  264.     je    @@vbedetectl11
  265.     stosb
  266.     jmp    @@vbedetectl10
  267. @@vbedetectl11:
  268.     xor    al,al                ; NULL terminate string
  269.     stosb
  270.  
  271.     jmp    @@vbedetect_ALMOSTDONE
  272.  
  273.  
  274.     ; set the VBE 2.0 strings to NULL
  275.  
  276. @@vbedetect_NOTVBE2:
  277.  
  278.     mov    [ebp].VBEINFOBLOCK.OemVendorNamePtr, edi
  279.     mov    [ebp].VBEINFOBLOCK.OemProductNamePtr, edi
  280.     mov    [ebp].VBEINFOBLOCK.OemProductRevPtr, edi
  281.     xor    al,al
  282.     stosb
  283.  
  284. @@vbedetect_ALMOSTDONE:
  285.  
  286.  
  287.     ; Check if we over-ran the local buffer
  288.  
  289.     cmp    edi,offset localBufEnd
  290.     jge    @@error
  291.  
  292.  
  293.     ; The Boca Vortex VBE implementation returns a version number of
  294.     ; 2.2, but it's really only VBE 1.2 (2.2 is the version number of
  295.     ; their VBE BIOS!
  296.  
  297.     cmp    [ebp].VBEINFOBLOCK.VbeVersion,0200h
  298.     jle    @@vbedetect_NOTMENTAL
  299.  
  300.     mov     esi,[ebp].VBEINFOBLOCK.OemStringPtr
  301.     mov    edi,offset vortexStr
  302.  
  303.     mov    ecx,6
  304.  
  305. @@vbedetectl12:
  306.     lodsb
  307.     cmp    byte ptr [edi],al
  308.     jne    @@vbedetect_NOTMENTAL
  309.     loop    @@vbedetectl12
  310.     mov    [ebp].VBEINFOBLOCK.VbeVersion,0102h
  311.  
  312. @@vbedetect_NOTMENTAL:
  313.  
  314.  
  315.     ; Release DOS memory then return pointer to vbeInfo struct
  316.  
  317.     mov    ax, 0101h            ; free dos memory buffer
  318.     mov    dx, dosmem_selector
  319.     int    031h
  320.     popad
  321.     mov eax,offset vbeInfo
  322.     ret
  323.  
  324.  
  325.     ; Release DOS memory then return Null
  326.  
  327. @@error:
  328.     mov    ax, 0101h            ; free dos memory buffer
  329.     mov    dx, dosmem_selector
  330.     int    031h
  331.     popad
  332.     mov eax,0
  333.     ret
  334.  
  335. vbeDetect_    endp
  336.  
  337. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  338. ; vbeGetModeInfo
  339. ; Setup up a video mode
  340. ;
  341. ; In:
  342. ;   EAX -  Mode
  343. ;   EDX -> Address of VBEMODEINFO structure
  344. ;
  345. ; Out:
  346. ;    Returns 1, mode info has been copied to the VBEMODEINFO structure.
  347. ;    Otherwise returns 0 for failure.
  348. ;
  349. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  350. vbeGetModeInfo_    proc
  351.  
  352.     pushad
  353.  
  354.     ; Save pointer
  355.  
  356.     mov    vbeTempVar,eax
  357.     mov    vbeTempPointer,edx
  358.  
  359.     ; Get the vbeInfo block
  360.  
  361.     call    vbeDetect_
  362.     cmp    eax,0
  363.     je    @@vbeinfo_NOTFOUND        ; VBE detect error
  364.  
  365.     ; Allocate low memory buffer for
  366.     ; communcation with VBE
  367.  
  368.     mov    ax, 0100h
  369.     mov    bx, 512/16
  370.     int    031h
  371.     jnc    @@vbeinfol1
  372.  
  373.     popad
  374.     xor    eax,eax
  375.     ret
  376.  
  377. @@vbeinfol1:
  378.  
  379.     ; Save the real mode info
  380.  
  381.     mov    ecx,eax
  382.     and    ecx,0FFFFh
  383.     shl    ecx,4
  384.     mov    dosmem_address,ecx        ; save linear address
  385.     mov    dosmem_segment,ax
  386.     mov    dosmem_selector,dx
  387.  
  388.     mov    bx,ax                ; bx = dosmem_segment
  389.  
  390.     mov    ebp,offset vbeInfo
  391.     mov    ebp,dosmem_address
  392.  
  393.     ; Get the VBE mode infomation block
  394.  
  395.     mov    eax,vbeTempVar
  396.     mov     edi,offset RMREGS
  397.     mov     rm_eax, 04f01h
  398.     mov    rm_ebx, 0
  399.     mov     rm_ecx, eax
  400.     mov    ax,dosmem_segment
  401.     mov    rm_es, ax
  402.     mov     rm_edi, 0
  403.  
  404.     mov     ax, 0300h            ; simulate real mode int
  405.     mov     bl, 010h
  406.     mov    bh, 0
  407.     mov     cx, 0
  408.     int     031h
  409.     jc    @@vbeinfo_NOTFOUND        ; DPMI error
  410.     mov    eax,rm_eax
  411.     cmp     al,04fh
  412.     jne    @@vbeinfo_NOTFOUND        ; vbe not detected
  413.  
  414.     ; Copy block to passed structure
  415.  
  416.     mov    edi, vbeTempPointer
  417.     mov    esi, ebp
  418.     mov    ecx, size MODEINFOBLOCK
  419.     rep    movsb
  420.  
  421.     ; Cleanup
  422.  
  423.     mov    ax, 0101h            ; free dos memory buffer
  424.     mov    dx, dosmem_selector
  425.     int    031h
  426.     popad
  427.     mov    eax,1
  428.     ret
  429.  
  430. @@vbeinfo_NOTFOUND:
  431.  
  432.     mov    ax, 0101h            ; free dos memory buffer
  433.     mov    dx, dosmem_selector
  434.     int    031h
  435.     popad
  436.     mov    eax,0
  437.     ret
  438.  
  439.  
  440. vbeGetModeInfo_    endp
  441.  
  442.  
  443.  
  444.  
  445. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  446. ; vbeOpen
  447. ; Setup up a video mode
  448. ;
  449. ; In:
  450. ;   EAX - X res
  451. ;   EDX - Y res
  452. ;   EBX - Colour depth
  453. ;
  454. ; Out:
  455. ;    EAX - returns pointer to a VESASURFACE structure,
  456. ;          or NULL on failure
  457. ;
  458. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  459. vbeOpen_    proc
  460.  
  461.     pushad
  462.  
  463.     ; Check we're not already open
  464.  
  465.     cmp    vbeInit,1
  466.     je    @@vbeopen_NOTFOUND
  467.  
  468.     ; Save requested mode info
  469.  
  470.     mov    vbeScreenWidth,eax
  471.     mov    vbeScreenHeight,edx
  472.     mov    vbeScreenBits,bl
  473.  
  474.  
  475.     ; Get the vbeInfo block
  476.  
  477.     call    vbeDetect_
  478.     cmp    eax,0
  479.     je    @@vbeopen_NOTFOUND        ; VBE detect error
  480.  
  481.  
  482.     ; Allocate low memory buffer for
  483.     ; communcation with VBE
  484.  
  485.     mov    ax, 0100h
  486.     mov    bx, 512/16
  487.     int    031h
  488.     jnc    @@vbedetectl1
  489.  
  490.     popad
  491.     xor    eax,eax
  492.     ret
  493.  
  494. @@vbedetectl1:
  495.  
  496.  
  497.     ; Save the real mode info
  498.  
  499.     mov    ecx,eax
  500.     and    ecx,0FFFFh
  501.     shl    ecx,4
  502.     mov    dosmem_address,ecx        ; save linear address
  503.     mov    dosmem_segment,ax
  504.     mov    dosmem_selector,dx
  505.  
  506.     mov    bx,ax                ; bx = dosmem_segment
  507.  
  508.  
  509.     ; Scan mode list for the mode
  510.  
  511.     mov    ebp,offset vbeInfo
  512.     mov    esi,[ebp].VBEINFOBLOCK.VideoModePtr
  513.     mov    ebp,dosmem_address
  514.  
  515.     xor     eax,eax
  516.  
  517. @@vbeopenl1:
  518.     lodsw
  519.     cmp    ax, -1                      ; End of list
  520.     je    @@vbeopen_NOTFOUND
  521.  
  522.     mov    vbeMode,ax            ; Save mode number
  523.  
  524.     ; Get the VBE mode infomation block
  525.  
  526.     mov     edi,offset RMREGS
  527.     mov     rm_eax, 04f01h
  528.     mov    rm_ebx, 0
  529.     mov     rm_ecx, eax
  530.     mov    ax,dosmem_segment
  531.     mov    rm_es, ax
  532.     mov     rm_edi, 0
  533.  
  534.     mov     ax, 0300h            ; simulate real mode int
  535.     mov     bl, 010h
  536.     mov    bh, 0
  537.     mov     cx, 0
  538.     int     031h
  539.     jc    @@vbeopen_NOTFOUND        ; DPMI error
  540.     mov    eax,rm_eax
  541.     cmp     al,04fh
  542.     jne    @@vbeopen_NOTFOUND        ; vbe not detected
  543.  
  544.     ; Check this is the mode we want
  545.  
  546.     movzx   eax, [ebp].MODEINFOBLOCK.XResolution
  547.     cmp     eax, vbeScreenWidth
  548.     jnz    @@vbeopenl1
  549.     movzx    eax, [ebp].MODEINFOBLOCK.YResolution
  550.     cmp    eax, vbeScreenHeight
  551.     jnz    @@vbeopenl1
  552.     mov    al, [ebp].MODEINFOBLOCK.BitsPerPixel
  553.     cmp    al, vbeScreenBits
  554.     jnz    @@vbeopenl1
  555.  
  556.     ; This is our mode, try setting it with LFB on
  557.  
  558.     mov    ax, 04f02h
  559.     mov        bx, vbeMode
  560.     or    bx, 4000h            ; ask for LFB
  561.     int    010h
  562.     cmp    ah, 0
  563.     jnz    @@vbeopen_NOLFB
  564.  
  565.     ; Map LFB memory
  566.  
  567.     mov     ebx, [ebp].MODEINFOBLOCK.PhysBasePtr
  568.     mov     ecx, ebx
  569.     shr     ebx, 16                 ; BX:CX = physical base ptr
  570.  
  571.     mov     esi, (4096*1024)-1    ; 4Meg
  572.     mov     edi, esi
  573.     shr     esi, 16                 ; SI:DI = region size
  574.  
  575.     mov     ax, 0800h
  576.     int     031h
  577.     jc    @@vbeopen_NOTFOUND    ; DPMI error
  578.  
  579.     shl     ebx, 16
  580.     mov     bx, cx
  581.     mov     vbeLfbPtr, ebx      ; Save LFB pointer
  582.  
  583.     jmp     @@vbeopen_OK
  584.  
  585.  
  586.     ; No LFB available
  587.  
  588. @@vbeopen_NOLFB:
  589.  
  590.     ;
  591.     ;
  592.     ; We should set up a virtual linear fraem buffer
  593.     ; here, but I'll do that later.
  594.     ;
  595.     ;
  596.     jmp    @@vbeopen_NOTFOUND
  597.  
  598.  
  599. @@vbeopen_OK:
  600.  
  601.     ; Set scan line width to be sure
  602.  
  603.     mov    ecx, vbeScreenWidth
  604.     mov     eax, 04f06h
  605.     xor     ebx, ebx
  606.     xor     edx, edx
  607.     int     010h
  608.  
  609.     ; Set init
  610.  
  611.     mov    vbeInit,1
  612.  
  613.     ; build the vbe surface structure
  614.  
  615.     mov    edi,offset vbeSurface
  616.  
  617.     xor    eax,eax
  618.     mov    ax,vbeMode
  619.     mov    [edi].VBESURFACE.mode,eax
  620.  
  621.     mov    eax,vbeScreenWidth
  622.     mov    [edi].VBESURFACE.width,eax
  623.     mov    eax,vbeScreenHeight
  624.     mov    [edi].VBESURFACE.height,eax
  625.  
  626.     movzx    eax,vbeScreenBits
  627.     mov    [edi].VBESURFACE.bits,eax
  628.     shr    eax,3
  629.     mov    [edi].VBESURFACE.depth,eax
  630.  
  631.     mov    eax,vbeLfbPtr
  632.     mov    [edi].VBESURFACE.lfb,eax
  633.  
  634.     mov    ax, 0101h            ; free dos memory buffer
  635.     mov    dx, dosmem_selector
  636.     int    031h
  637.     popad
  638.     mov    eax,offset vbeSurface
  639.     ret
  640.  
  641.  
  642. @@vbeopen_NOTFOUND:
  643.  
  644.     mov    ax, 0101h            ; free dos memory buffer
  645.     mov    dx, dosmem_selector
  646.     int    031h
  647.     popad
  648.     mov    eax,0
  649.     ret
  650.  
  651.  
  652. vbeOpen_    endp
  653.  
  654.  
  655. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  656. ; vbeClose
  657. ; Close the driver
  658. ;
  659. ; In:
  660. ;   EAX - VBESURFACE
  661. ;
  662. ; Out:
  663. ;   NONE
  664. ;
  665. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  666. vbeClose_    proc
  667.  
  668.     pushad
  669.  
  670.     ; Check we're open
  671.  
  672.     cmp    vbeInit,0
  673.     je    @@vbeclose_END
  674.  
  675.  
  676.     ;
  677.     ; We should check for a virtual LFB and
  678.     ; get rid of it
  679.     ;
  680.  
  681.  
  682.     ; Release LFB mapping
  683.  
  684.     mov     ax, 0801h
  685.     mov     ebx, vbeLfbPtr
  686.     mov     ecx, ebx
  687.     shr     ebx, 16
  688.     int     031h            ; release mapping
  689.  
  690.  
  691.     ; Reset video mode
  692.  
  693.     mov    eax,03h
  694.     int    010h
  695.  
  696.     mov    vbeInit,0
  697.  
  698. @@vbeclose_END:
  699.     popad
  700.     ret
  701.  
  702. vbeClose_    endp
  703.  
  704. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  705. ; vbeSetScanWidth
  706. ; Set pixels per scan line of the display
  707. ;
  708. ; In:
  709. ;   EAX - Pixels per scan line
  710. ;
  711. ; Out:
  712. ;    Returns 1, new pixels per scan line set.
  713. ;    Otherwise returns 0 for failure.
  714. ;
  715. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  716. vbeSetScanWidth_    proc
  717.  
  718.     push ebx ecx edx
  719.     mov    ecx,eax
  720.  
  721.     mov     eax, 04f06h
  722.     xor     ebx, ebx
  723.     xor     edx, edx
  724.     int     010h
  725.  
  726.     cmp     al,04fh
  727.     jne    @@vbesetscan_NOTFOUND        ; vbe not detected
  728.  
  729.     mov    eax,1
  730.     pop edx ecx ebx
  731.     ret
  732.  
  733. @@vbesetscan_NOTFOUND:
  734.     mov    eax,0
  735.     pop edx ecx ebx
  736.     ret
  737.  
  738. vbeSetScanWidth_    endp
  739.  
  740.  
  741. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  742. ; vbeGetScanWidth
  743. ; Get number of pixels per scan line
  744. ;
  745. ; In:
  746. ;   NONE
  747. ;
  748. ; Out:
  749. ;    Returns pixels per scan line, or 0 for failure.
  750. ;
  751. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  752. vbeGetScanWidth_    proc
  753.  
  754.     push ebx ecx edx
  755.  
  756.     mov     eax, 04f06h
  757.     mov     ebx, 1
  758.     xor    ecx, ecx
  759.     int     010h
  760.  
  761.     cmp     al,04fh
  762.     jne    @@vbegetline_NOTFOUND        ; vbe not detected
  763.  
  764.     mov    eax,ecx
  765.     pop edx ecx ebx
  766.     ret
  767.  
  768. @@vbegetline_NOTFOUND:
  769.     mov    eax,0
  770.     pop edx ecx ebx
  771.     ret
  772.  
  773. vbeGetScanWidth_    endp
  774.  
  775. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  776. ; vbeSetDisplayStart
  777. ; Set new display start position
  778. ; Does NOT wait for vr.
  779. ;
  780. ; In:
  781. ;   EAX - new x position
  782. ;   EDX - new y position
  783. ;
  784. ; Out:
  785. ;    Returns 1, new display position set.
  786. ;    Otherwise returns 0 for failure.
  787. ;
  788. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  789. vbeSetDisplayStart_    proc
  790.  
  791.     push ebx ecx edx
  792.     mov    ecx,eax
  793.  
  794.     mov     eax, 04f07h
  795.     xor     ebx, ebx
  796.     int     010h
  797.  
  798.     cmp     al,04fh
  799.     jne    @@vbesetdisp_NOTFOUND        ; vbe not detected
  800.  
  801.     mov    eax,1
  802.     pop edx ecx ebx
  803.     ret
  804.  
  805. @@vbesetdisp_NOTFOUND:
  806.     mov    eax,0
  807.     pop edx ecx ebx
  808.     ret
  809.  
  810. vbeSetDisplayStart_    endp
  811.  
  812. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  813. ; vbeGetDisplayStart
  814. ; Get the display start position
  815. ;
  816. ; In:
  817. ;   EAX -> address of where to put x position (1 DWORD)
  818. ;   EDX -> address of where to put y position (1 DWORD)
  819. ;
  820. ; Out:
  821. ;    Returns 1, if x and y data was set.
  822. ;    Otherwise returns 0 for failure.
  823. ;
  824. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  825. vbeGetDisplayStart_    proc
  826.  
  827.     push ebx ecx edx
  828.     push eax edx
  829.  
  830.     mov     eax, 04f07h
  831.     mov     ebx, 1
  832.     xor    edx,edx
  833.     xor    ecx,ecx
  834.     int     010h
  835.  
  836.     cmp     al,04fh
  837.     jne    @@vbegetdisp_NOTFOUND        ; vbe not detected
  838.  
  839.     pop eax                    ; get Y address
  840.     mov    dword ptr [eax],edx
  841.     pop edx                    ; get X address
  842.     mov    dword ptr [edx],ecx
  843.  
  844.     mov    eax,1
  845.     pop edx ecx ebx
  846.     ret
  847.  
  848. @@vbegetdisp_NOTFOUND:
  849.     pop edx eax
  850.     mov    eax,0
  851.     pop edx ecx ebx
  852.     ret
  853.  
  854. vbeGetDisplayStart_    endp
  855.  
  856.  
  857. ;─────────────────────────────────────────────────────────────────────────────
  858. ends
  859.  
  860.  
  861.  
  862.  
  863.  
  864. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  865. ; DATA
  866. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  867. _DATA   segment use32 dword public 'DATA'
  868.     assume  ds:_DATA
  869. ;─────────────────────────────────────────────────────────────────────────────
  870.  
  871. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  872. ; DPMI Real mode register structure
  873. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  874.  
  875. RMREGS    label    dword
  876.         rm_edi          dd    ?
  877.         rm_esi        dd    ?
  878.         rm_ebp        dd    ?
  879.         rm_esp        dd    ?
  880.         rm_ebx        dd    ?
  881.         rm_edx        dd    ?
  882.         rm_ecx        dd    ?
  883.         rm_eax        dd    ?
  884.  
  885.         rm_flags    dw    ?
  886.         rm_es        dw    ?
  887.         rm_ds        dw    ?
  888.         rm_fs        dw    ?
  889.         rm_gs        dw    ?
  890.         rm_ip        dw    ?
  891.         rm_cs        dw    ?
  892.         rm_sp        dw    ?
  893.         rm_ss        dw    ?
  894.         rm_spare_data    dd    20 dup(?)
  895.  
  896. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  897. ; VBE Infomation Block
  898. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  899. VBEINFOBLOCK    STRUC
  900.  
  901.  
  902. VbeSignature        db 'VESA'        ; VBE Signature
  903. VbeVersion          dw 0200h         ; VBE Version
  904. OemStringPtr        dd ?             ; Pointer to OEM String
  905. Capabilities        db 4 dup (?)     ; Capabilities of graphics cont.
  906. VideoModePtr        dd ?             ; Pointer to Video Mode List
  907. TotalMemory         dw ?             ; Number of 64kb memory blocks
  908.  
  909.     ; Added for VBE 2.0
  910.  
  911. OemSoftwareRev      dw ?             ; VBE implementation Software revision
  912. OemVendorNamePtr    dd ?             ; Pointer to Vendor Name String
  913. OemProductNamePtr   dd ?             ; Pointer to Product Name String
  914. OemProductRevPtr    dd ?             ; Pointer to Product Revision String
  915. _Reserved_          db 222 dup (?)   ; Reserved for VBE implementation
  916.  
  917.     ; scratch area
  918.  
  919. OemData             db   256 dup (?) ; Data Area for OEM Strings
  920.  
  921. VBEINFOBLOCK    ENDS
  922.  
  923.  
  924. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  925. ; VBE Mode Infomation Block
  926. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  927. MODEINFOBLOCK   STRUC
  928.  
  929.     ; Mandatory information for all VBE revisions:
  930.  
  931. ModeAttributes      dw ?        ; mode attributes
  932. WinAAttributes      db ?        ; window A attributes
  933. WinBAttributes      db ?        ; window B attributes
  934. WinGranularity      dw ?        ; window granularity
  935. WinSize             dw ?        ; window size
  936. WinASegment         dw ?        ; window A start segment
  937. WinBSegment         dw ?        ; window B start segment
  938. WinFuncPtr          dd ?        ; pointer to window function
  939. BytesPerScanLine    dw ?        ; bytes per scan line
  940.  
  941.     ; Mandatory information for VBE 1.2 and above:
  942.  
  943. XResolution         dw ?        ; horizontal resolution in pixels or chars
  944. YResolution         dw ?        ; vertical resolution in pixels or chars
  945. XCharSize           db ?        ; character cell width in pixels
  946. YCharSize           db ?        ; character cell height in pixels
  947. NumberOfPlanes      db ?        ; number of memory planes
  948. BitsPerPixel        db ?        ; bits per pixel
  949. NumberOfBanks       db ?        ; number of banks
  950. MemoryModel         db ?        ; memory model type
  951. BankSize            db ?        ; bank size in KB
  952. NumberOfImagePages  db ?        ; number of images
  953. _Reserved           db ?        ; reserved for page function
  954.  
  955.     ; Direct Color fields (required for direct/6 and YUV/7 memory models)
  956.  
  957. RedMaskSize         db ?        ; size of direct color red mask in bits
  958. RedFieldPosition    db ?        ; bit position of lsb of red mask
  959. GreenMaskSize       db ?        ; size of direct color green mask in bits
  960. GreenFieldPosition  db ?        ; bit position of lsb of green mask
  961. BlueMaskSize        db ?        ; size of direct color blue mask in bits
  962. BlueFieldPosition   db ?        ; bit position of lsb of blue mask
  963. RsvdMaskSize        db ?        ; size of direct color reserved mask in bits
  964. RsvdFieldPosition   db ?        ; bit position of lsb of reserved mask
  965. DirectColorModeInfo db ?        ; direct color mode attributes
  966.  
  967.     ; Mandatory information for VBE 2.0 and above:
  968.  
  969. PhysBasePtr         dd ?        ; physical address for flat frame buffer
  970. OffScreenMemOffset  dd ?        ; pointer to start of off screen memory
  971. OffScreenMemSize    dw ?        ; amount of off screen memory in 1k units
  972. __Reserved          db 206 dup (?)
  973.  
  974. MODEINFOBLOCK    ENDS
  975.  
  976.  
  977. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  978. ; VBE SURFACE
  979. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  980. VBESURFACE    STRUC
  981.  
  982. mode            dd    ?
  983. width            dd    ?
  984. height            dd    ?
  985. bits            dd    ?
  986. depth            dd    ?
  987. lfb            dd    ?
  988.  
  989. VBESURFACE    ENDS
  990.  
  991.  
  992. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  993. ; DATA
  994. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  995. ALIGN 4
  996. vbeInfo        VBEINFOBLOCK    <?>
  997.  
  998. ALIGN 4
  999. vbeSurface      VBESURFACE    <?>
  1000.  
  1001. ALIGN 4
  1002.  
  1003. vbeInit        dd    0
  1004.  
  1005. vbeMode        dw    ?,?
  1006. vbeScreenWidth    dd    ?
  1007. vbeScreenHeight    dd    ?
  1008. vbeScreenBits    db    ?,?,?,?
  1009. vbeLfbPtr    dd    ?
  1010.  
  1011. vbeTempVar    dd    ?
  1012. vbeTempPointer    dd    ?
  1013.  
  1014. dosmem_segment    dw      ?,?
  1015. dosmem_selector    dw      ?,?
  1016. dosmem_address    dd      ?
  1017.  
  1018. localBuf    label    dword
  1019.         db    1024 dup(?)
  1020. localBufEnd    label    dword
  1021.  
  1022. vortexStr    db    'VORTEX'
  1023.  
  1024.  
  1025.  
  1026. ;─────────────────────────────────────────────────────────────────────────────
  1027. ends
  1028.  
  1029. end
  1030.